import { Component } from "react";
import { CelimaList } from "../../apis/movie";
import style from './cinemalist.module.css'

export default class Cinemalist extends Component {
    state = {
        cinemaList: []
    }
    async componentDidMount() {
        let res = await CelimaList()
        this.setState({
            cinemaList: res.data.data
        })
    }
    render() {
        // console.log(this.state.cinemaList);
        return (
            <>
                {
                    this.state.cinemaList.map(item =>
                        <div key={item.cid} className={style.cinema} onClick={this.clickName.bind(this, item)}>
                            <h3 className={style.title}>{item.name}</h3>
                            <p>{item.address}</p>
                            <p className={style.price}>￥{item.price}</p>
                            <p className={style.boot}>{item.type}</p>
                        </div>
                    )
                }
            </>
        )
    }
    clickName(item) {
        // console.log(item);
        sessionStorage.setItem('cinema', JSON.stringify(item))
        window.location.href = '/#/cin'
    }
}